# coding=utf-8
# __author__ = "James Zhang"
# !/usr/bin/python
# -*- coding: utf-8 -*-
from core.handler import base


class IndexPageHandler(base.BaseHandler):
    def get(self, *args, **kwargs):
        # self.session['username'] = 'jameszhang'     # 使用session
        self.render(r'demo/index.html')


class VideoHandler(base.BaseHandler):
    def get(self, *args, **kwargs):
        self.render(r'demo/demo360.html')


clients = set()


class WebSocketHandler(base.WebSocketHandler):

    def open(self, *args, **kwargs):
        print('start..........', clients)
        clients.add(self)
        pass

    def on_message(self, message):
        print('receiver message: ', message)
        for client in clients:
            client.write_message("message was: " + message)

    def on_close(self):
        clients.remove(self)
        print("close websocket!")

